package inputmanager;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


public class InputMgr implements KeyListener {

	private boolean w;
	private boolean a;
	private boolean s;
	private boolean d;
	private boolean o;
	private boolean p;
	private boolean esc;
	private boolean w_press;
	private boolean a_press;
	private boolean s_press;
	private boolean d_press;
	private boolean o_press;
	private boolean p_press;
	private boolean esc_press;

	@Override
	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_W){
			w = true;
			w_press = true;
		}
		else if (key == KeyEvent.VK_A){
			a = true;
			a_press = true;
		}
		else if (key == KeyEvent.VK_S){
			s = true;
			s_press = true;
		}
		else if (key == KeyEvent.VK_D){
			d = true;
			d_press = true;
		}
		else if (key == KeyEvent.VK_O){
			o = true;
			o_press = true;
		}
		else if (key == KeyEvent.VK_P){
			p = true;
			p_press = true;
		}
		else if (key == KeyEvent.VK_ESCAPE){
			esc = true;
			esc_press = true;
		}
		
	}
	
	@Override
	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_W){
			w = false;
			w_press = false;
		}
		else if (key == KeyEvent.VK_A){
			a = false;
			a_press = false;
		}
		else if (key == KeyEvent.VK_S){
			s = false;
			s_press = false;
		}
		else if (key == KeyEvent.VK_D){
			d = false;
			d_press = false;
		}
		else if (key == KeyEvent.VK_O){
			o = false;
			o_press = false;
		}
		else if (key == KeyEvent.VK_P){
			p = false;
			p_press = false;
		}
		else if (key == KeyEvent.VK_ESCAPE){
			esc = false;
			esc_press = false;
		}
		
	}
	
	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub	
	}
	
	public void resetPress(){
		w_press = false;
		a_press = false;
		s_press = false;
		d_press = false;
		o_press = false;
		p_press = false;
		esc_press = false;
	}
	
	public boolean getKeyState(char k){
		if (k == 'W')
			return w;
		else if (k == 'A')
			return a;
		else if (k == 'S')
			return s;
		else if (k == 'D')
			return d;
		else if (k == 'O')
			return o;
		else if (k == 'P')
			return p;
		else if (k == 'E')
			return esc;
		else if (k == 'w')
			return w_press;
		else if (k == 'a')
			return a_press;
		else if (k == 's')
			return s_press;
		else if (k == 'd')
			return d_press;
		else if (k == 'o')
			return o_press;
		else if (k == 'p')
			return p_press;
		else if (k == 'e')
			return esc_press;
		else
			return false;
	}
}
